package day16.problem1;

//字符串替换
//https://www.nowcoder.com/practice/f094aed769d84cf3b799033c82fc1bf6?tpId=182&tqId=34710&ru=/exam/oj

import java.util.*;

public class StringFormat {
    public String formatString(String A, int n, char[] arg, int m) {
        int index = 0;
        StringBuffer ret = new StringBuffer();
        int i= 0;
        while(i < n) {
            if(A.charAt(i) == '%' && i + 1 < n && A.charAt(i+1) == 's') {
                ret.append(arg[index++]);
                i+=2;
            }else {
                ret.append(A.charAt(i));
                i++;
            }
        }
        while(index < m) {
            ret.append(arg[index++]);
        }
        return ret.toString();
    }
}